import UIKit
/**
    B站：https://www.bilibili.com/video/BV144411C7Gg?p=26

    第26课
        1. 类的定义和使用
        2. 类的实例 传递(值引用)
 */

class Student {
    private var name: String = ""
    private var age: Int = -1
    private var score: Double = -1.0
    private var isPass: Bool = false
    
    static let schoolName = "哈佛大学"
    
    // https://swiftgg.gitbook.io/swift/swift-jiao-cheng/14_initialization#syntax-for-designated-and-convenience-initializers
    // 某种情况下通过使用便利构造器来快捷调用某个指定构造器，能够节省更多开发时间并让类的构造过程更清晰明了。
    convenience init() {
        self.init(name: "unknow", age: 0, score: 0.0)
    }
    
    init(name: String, age: Int, score: Double) {
        self.name = name
        self.age = age
        self.score = score
        
        if (score < 60) {
            self.isPass = false
        } else {
            self.isPass = true
        }
    }
}



/**
     为了说明，convenience 仅用于 init,写了下面例子
     convenience [kənˈviːniəns]  n. 方便;适宜;便利
 */
class Dog {
    var name: String = ""
    var age: Int = 0
    
    func getName() -> String {
        return self.getName(pre: "过来，来! ", age: self.age)
    }
    
    func getName(pre: String, age: Int) -> String {
        return pre + self.name + " " + String(age) + "岁拉"
    }
}

var d = Dog()
d.name = "金毛"
d.age = 1
print(d.getName())
